home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / WIN_PRO / OWLCTL.ZIP;1 / UTY25001.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-22  |  45.2 KB  |  1,820 lines

  1.  
  2. /******************************************************************************
  3. *                                                                             *
  4. *                                                                             *
  5. ******************************************************************************/
  6.  
  7.  
  8. #include <windows.h>
  9. #include <mem.h>
  10. #include <uty00000.h>
  11. //#include <custcntl.h>
  12. #include <uty25001.h>
  13. #include <uty25002.h>
  14.  
  15. #ifdef WIN32
  16.  
  17. #define _loadds
  18.  
  19. //
  20. // Common Dialogs
  21. //  - Win32 dll has different name.
  22. //  - GetProcAddress() is case sensitive.
  23. //
  24. #define szCommDlgName            "comdlg32.dll"
  25. #define szCDDwLbSubclass        "dwLBSubclass"
  26. #define szCDEditIntegerOnly    "EditIntegerOnly"
  27.  
  28. #define FValidLibHandle(hlib)    ((hlib) != NULL)
  29.  
  30. //
  31. // No concept of far in Win32.
  32. //
  33.  
  34. #define MEMICMP                 memicmp
  35.  
  36. //
  37. // Control IDs are LONG in Win32.
  38. //
  39.  
  40. typedef LONG CTLID;
  41. #define GetControlId(hwnd) GetWindowLong(hwnd, GWL_ID)
  42.  
  43. //
  44. // Send a color button message.
  45. //
  46.  
  47. #define SEND_COLOR_BUTTON_MESSAGE( hwndParent, hwnd, hdc )      \
  48.     ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLORBTN, (WPARAM) hdc, (LPARAM) hwnd))
  49.  
  50. //
  51. // Send a color static message.
  52. //
  53.  
  54. #define SEND_COLOR_STATIC_MESSAGE( hwndParent, hwnd, hdc )      \
  55.     ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLORSTATIC, (WPARAM) hdc, (LPARAM) hwnd))
  56.  
  57. #else
  58.  
  59.  
  60. #define szCommDlgName             "commdlg.dll"
  61. #define szCDDwLbSubclass     "DWLBSUBCLASS"
  62. #define szCDEditIntegerOnly  "EDITINTEGERONLY"
  63.  
  64. #define FValidLibHandle(hlib)    (( hlib ) > 32 )
  65.  
  66. #define MEMICMP                 _fmemicmp
  67.  
  68. typedef WORD CTLID;
  69. #define GetControlId( h )       GetWindowWord( h, GWW_ID )
  70.  
  71. #define SEND_COLOR_BUTTON_MESSAGE( hwndParent, hwnd, hdc )      \
  72.     ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLOR, (WORD) hdc, MAKELONG(hwnd, CTLCOLOR_BTN)))
  73.  
  74. #define SEND_COLOR_STATIC_MESSAGE( hwndParent, hwnd, hdc )      \
  75.     ((HBRUSH) SendMessage(hwndParent, WM_CTLCOLOR, (WORD) hdc, MAKELONG(hwnd, CTLCOLOR_STATIC)))
  76.  
  77. #endif // WIN32
  78.  
  79.  
  80.  
  81. // Index Color Table
  82. // WARNING: change mpicvSysColors if you change the icv order
  83. typedef WORD ICV;
  84.  
  85. #define icvBtnHilite 0
  86. #define icvBtnFace 1
  87. #define icvBtnShadow 2
  88. #define icvBtnText 3
  89. #define icvWindow 4
  90. #define icvWindowText 5
  91. #define icvGrayText 6
  92. #define icvWindowFrame 7
  93. #define icvForceBlack 8
  94. #define icvForceLTGray 9
  95. #define icvForceDKGray 10
  96. #define icvForceWhite 11
  97. #define icvMax 12 
  98. #define icvSysMax 8
  99.  
  100. #define icvSysBrushMax 3
  101. #define icvBrushMax 5
  102. #define icvBRBack 3
  103. #define icvBRLTGray 4
  104.  
  105.  
  106. typedef COLORREF CV;
  107.  
  108. // CoLoR Table
  109. typedef struct
  110.     {
  111.     CV rgcv[icvMax];
  112.     } CLRT;
  113.  
  114.  
  115. // BRush Table
  116. typedef struct
  117.     {
  118.     HBRUSH mpicvhbr[icvBrushMax];
  119.     } BRT;
  120.  
  121.  
  122. // DrawRec3d flags
  123. #define dr3Left  0x0001
  124. #define dr3Top   0x0002
  125. #define dr3Right 0x0004
  126. #define dr3Bot   0x0008
  127.  
  128. #define dr3HackBotRight 0x1000    // code size is more important than aesthetics
  129. #define dr3All      0x000f
  130. typedef WORD DR3;
  131.  
  132. #define BFCHECK        0x0003
  133. #define BFSTATE        0x0004
  134. #define BFFOCUS        0x0008
  135. #define BFINCLICK   0x0010    /* Inside click code */
  136. #define BFCAPTURED  0x0020    /* We have mouse capture */
  137. #define BFMOUSE        0x0040    /* Mouse-initiated */
  138. #define BFDONTCLICK 0x0080    /* Don't check on get focus */
  139.  
  140. #define bpText  0x0002
  141. #define bpCheck 0x0004
  142. #define bpFocus 0x0008    // must be same as BFFOCUS
  143. #define bpBkgnd 0x0010
  144.  
  145.  
  146.  
  147. //
  148. // Control Types
  149. // Commdlg types are necessary because commdlg.dll subclasses certain 
  150. // controls before the app can call Ctl3dSubclassDlg.
  151. #define ctButton            0
  152. #define ctList                1
  153. #define ctEdit                2
  154. #define ctCombo            3
  155. #define ctStatic            4
  156. #define ctListCommdlg    5
  157. #define ctEditCommdlg    6
  158. #define ctMax 7
  159.  
  160. // Windows Versions (Byte order flipped from GetWindowsVersion)
  161. #define ver30 0x0300
  162. #define ver31 0x030a
  163. #define ver40 0x0400
  164.  
  165. // Border widths
  166. #define dxBorder 1
  167. #define dyBorder 1
  168.  
  169. typedef struct
  170.     {
  171.     int xLeft;
  172.     int yTop;
  173.     int xRight;
  174.     int yBot;
  175.     } RC;
  176.  
  177. int mpicvSysColor[] =
  178.     {
  179.     COLOR_BTNHIGHLIGHT,
  180.     COLOR_BTNFACE,
  181.     COLOR_BTNSHADOW,
  182.     COLOR_BTNTEXT,
  183.     COLOR_WINDOW,
  184.     COLOR_WINDOWTEXT,
  185.     COLOR_GRAYTEXT,
  186.     COLOR_WINDOWFRAME
  187.     };
  188.  
  189.  
  190. //Globals
  191. short sCntUsers = 0;
  192.  
  193. WNDPROC wndprocEdit;
  194. WNDPROC wndprocButton;
  195. WNDPROC wndprocListBox;
  196. WNDPROC wndprocStatic;
  197. WNDPROC wndprocComboBox;
  198.  
  199. DLGPROC dlgprocUty;
  200. WORD verWindows;
  201. HINSTANCE hinstLib;
  202. BOOL bRegistered = FALSE;
  203.  
  204. HBITMAP hbmpCheckboxes;
  205. WORD grbitStyle = 0;
  206. #define bitFCoolButtons 0x0001
  207.  
  208. #define Assert(f)     
  209.  
  210. char szEditClass[] = "Uty3D_Edit";
  211. char szButtonClass[] = "Uty3D_Button";
  212. char szListBoxClass[] = "Uty3D_ListBox";
  213. char szStaticClass[] = "Uty3D_Static";
  214. char szComboBoxClass[] = "Uty3D_ComboBox";
  215.  
  216. char szDialogClass[] = "Uty3D_DLG";
  217.  
  218. CLRT clrt;
  219. BRT brt;
  220.  
  221.  
  222. //Prototypes
  223.  
  224. extern "C" 
  225. {
  226. LRESULT _loadds FAR PASCAL EditWndProc3d(HWND hwnd,
  227.                                          UINT wm,
  228.                                          WPARAM wParam,
  229.                                          LPARAM lParam);
  230.  
  231. LRESULT _loadds FAR PASCAL ButtonWndProc3d(HWND hwnd,
  232.                                            UINT wm,
  233.                                            WPARAM wParam,
  234.                                            LPARAM lParam);
  235.  
  236. LRESULT _loadds FAR PASCAL ListBoxWndProc3d(HWND hwnd,
  237.                                             UINT wm,
  238.                                             WPARAM wParam,
  239.                                             LPARAM lParam);
  240.  
  241. LRESULT _loadds FAR PASCAL StaticWndProc3d(HWND hwnd,
  242.                                            UINT wm,
  243.                                            WPARAM wParam,
  244.                                            LPARAM lParam);
  245.  
  246. LRESULT _loadds FAR PASCAL ComboBoxWndProc3d(HWND hwnd,
  247.                                              UINT wm,
  248.                                              WPARAM wParam,
  249.                                              LPARAM lParam);
  250. LRESULT _loadds FAR PASCAL DialogProc3d(HWND hwnd,
  251.                                         UINT wm,
  252.                                         WPARAM wParam,
  253.                                         LPARAM lParam);
  254.  
  255. } //extern "C"
  256.  
  257. LONG ShareEditComboWndProc3d(HWND hwnd, 
  258.                              UINT wm, 
  259.                              WPARAM wParam, 
  260.                              LPARAM lParam, 
  261.                              int ct);
  262.  
  263. void Inval3dCtl(HWND hwnd, 
  264.                 WINDOWPOS FAR *lpwp);
  265.  
  266. void ListEditPaint3d(HWND hwnd, 
  267.                      BOOL fEdit, 
  268.                      int ct);
  269.  
  270. void DrawInsetRect3d(HDC hdc, 
  271.                      RC FAR *prc, 
  272.                      DR3 dr3);
  273.  
  274. void DrawRec3d(HDC hdc, 
  275.                RC FAR *lprc, 
  276.                ICV icvUL, 
  277.                ICV icvLR, 
  278.                DR3 dr3);
  279.  
  280.  
  281. VOID BtnPaint(HWND hwnd,
  282.               HDC hdc,
  283.               int bp);
  284.  
  285. VOID DeleteBrushNull(HBRUSH FAR *ph);
  286. VOID DeleteObjects(VOID);
  287. BOOL RegisterClasses(HINSTANCE hInstance);
  288. VOID DrawPushButton(HWND hwnd,
  289.                     HDC hdc,
  290.                     RC FAR *lprc,
  291.                     LPSTR lpch,
  292.                     int cch,
  293.                     WORD bs,
  294.                     BOOL fDown);
  295.  
  296. VOID MyGetTextExtent(HDC hdc,
  297.                      LPSTR lpsz,
  298.                      int FAR *lpdx,
  299.                      int FAR *lpdy);
  300.  
  301. HBRUSH FAR PASCAL Ctl3dCtlColor(HDC hdc,
  302.                                 LONG lParam);
  303.  
  304. BOOL FUseWindowColors(HWND hwnd,
  305.                       int iType);
  306.  
  307. LONG SharedListWndProc(HWND hwnd,
  308.                        UINT wm,
  309.                        WPARAM wParam,
  310.                        LPARAM lParam,
  311.                        unsigned ct);
  312.  
  313. VOID ClipCtlDc(HWND hwnd,
  314.                HDC hdc);
  315.  
  316. void StaticPaint(HWND hwnd,
  317.                  HDC hdc);
  318.  
  319. void StaticPrint(HWND hwnd,
  320.                  HDC hdc,
  321.                  RC FAR *lprc,
  322.                  LONG style);
  323.  
  324. BOOL ComboCreate(HWND hwndCombo,
  325.                  CREATESTRUCT FAR *pcs);
  326.  
  327. /*******************************************************************
  328.     Function: LibMain(
  329.  
  330.        Description:
  331.  
  332. ********************************************************************/
  333.  
  334. int CALLBACK LibMain( HINSTANCE hInstance, WORD , WORD wHeap, LPSTR  )
  335. {
  336.    hinstLib = hInstance;
  337.  
  338.    if (wHeap > 0)
  339.       UnlockData( 0 );
  340.  
  341.  
  342.  
  343.    if (RegisterClasses(hInstance))
  344.    {
  345.       bRegistered = TRUE;
  346.    }
  347.    else
  348.    {
  349.       MessageBox(NULL, "Failed DLL Load", "Safe3D", MB_OK);
  350.       return 0;
  351.    }
  352.  
  353.    WORD wT = GetVersion();
  354.     verWindows = (LOBYTE(wT) << 8) | HIBYTE(wT);
  355.  
  356.  
  357.    return UtyCtlColorChange();
  358.  
  359.    //return 1;          
  360. }
  361.  
  362. /*******************************************************************
  363.     Function: WEP(
  364.  
  365.        Description:
  366.  
  367. ********************************************************************/
  368.  
  369. int FAR PASCAL WEP(int )
  370. {
  371.  
  372.    if (bRegistered)
  373.    {
  374.       UnregisterClass(szEditClass, hinstLib);
  375.       UnregisterClass(szButtonClass, hinstLib);
  376.       UnregisterClass(szDialogClass, hinstLib);
  377.       UnregisterClass(szListBoxClass, hinstLib);
  378.       UnregisterClass(szStaticClass, hinstLib);
  379.       UnregisterClass(szComboBoxClass, hinstLib);
  380.       DeleteObjects();
  381.    }
  382.  
  383.   return (1);
  384. }
  385.  
  386. /*******************************************************************
  387.     Function: EditWndProc3d(
  388.  
  389.        Description:
  390.  
  391. ********************************************************************/
  392.  
  393. LRESULT _loadds FAR PASCAL EditWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  394. {
  395.  
  396.     return ShareEditComboWndProc3d(hwnd, wm, wParam, lParam, ctEdit);
  397.  
  398. }
  399.  
  400. /*******************************************************************
  401.     Function: ButtonWndProc3d
  402.  
  403.        Description:
  404.  
  405. ********************************************************************/
  406.  
  407. LRESULT _loadds FAR PASCAL ButtonWndProc3d(HWND hwnd, UINT wm, WPARAM wParam, LPARAM lParam)
  408. {
  409.     //int ifrm3d;
  410.     LONG lRet;
  411.     LONG lStyle;
  412.     PAINTSTRUCT ps;
  413.     HDC hdc;
  414.     int bf;
  415.     int bfNew;
  416.     int bp;
  417.  
  418.     switch(wm)
  419.         {
  420.     case BM_SETSTATE:
  421.     case BM_SETCHECK:
  422.         bp = bpCheck;
  423.         goto DoIt;
  424.     case WM_KILLFOCUS:
  425.         // HACK! Windows will go into an infinit e loop trying to sync the
  426.         // states of the AUTO_RADIOBUTTON in this group.  (we turn off the
  427.         // visible bit so it gets skipped in the enumeration)
  428.         // Disable this code by clearing the STATE bit
  429.         if ((((int) GetWindowLong(hwnd, GWL_STYLE)) & 0x1F) == BS_AUTORADIOBUTTON)
  430.             SendMessage(hwnd, BM_SETSTATE, 0, 0L);
  431.         bp = 0;
  432.         goto DoIt;
  433.     case WM_ENABLE:
  434.         bp = bpCheck | bpText;
  435.         goto DoIt;
  436.     case WM_SETFOCUS:
  437.         // HACK! if wParam == NULL we may be activated via the task manager
  438.         // Erase background of control because a WM_ERASEBKGND messsage has not
  439.         // arrived yet for the dialog
  440.         bp = wParam == NULL ? (bpCheck | bpText | bpBkgnd) : (bpCheck | bpText);
  441. DoIt:
  442.         bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  443.         if((lStyle = GetWindowLong(hwnd, GWL_STYLE)) & WS_VISIBLE)
  444.             {
  445.             SetWindowLong(hwnd, GWL_STYLE, lStyle & ~(WS_VISIBLE));
  446.             lRet = CallWindowProc(wndprocButton, hwnd, wm, wParam, lParam);
  447.             SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE)|WS_VISIBLE);
  448.             bfNew = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  449.             if((wm != BM_SETSTATE && wm != BM_SETCHECK) ||
  450.                 bf != bfNew)
  451.                 {
  452.                 hdc = GetDC(hwnd);
  453.                 if (hdc != NULL)
  454.                     {
  455.                     Assert(BFFOCUS == bpFocus);
  456.                     /* If the check state changed, redraw no matter what,
  457.                         because it won't have during the above call to the def
  458.                         wnd proc */
  459.                     if ((bf & BFCHECK) != (bfNew & BFCHECK))
  460.                         bp |= bpCheck;
  461.                     ExcludeUpdateRgn(hdc, hwnd);
  462.                     BtnPaint(hwnd, hdc, bp|((bf^bfNew)&BFFOCUS));
  463.                     ReleaseDC(hwnd, hdc);
  464.                     }
  465.                 }
  466.             return lRet;
  467.             }
  468.         break;
  469.     case WM_PAINT:
  470.         bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  471.         if ((hdc = (HDC) wParam) == NULL)
  472.             hdc = BeginPaint(hwnd, &ps);
  473.         if(GetWindowLong(hwnd, GWL_STYLE) & WS_VISIBLE)
  474.             BtnPaint(hwnd, hdc, bpText|bpCheck|(bf&BFFOCUS));
  475.         if (wParam == NULL)
  476.             EndPaint(hwnd, &ps);
  477.         return 0L;
  478.         }
  479.     return CallWindowProc(wndprocButton, hwnd, wm, wParam, lParam);
  480.  
  481.  
  482. }
  483.  
  484. /*******************************************************************
  485.     Function: ListBoxWndProc3d(
  486.  
  487.        Description:
  488.  
  489. ********************************************************************/
  490.  
  491. LRESULT _loadds FAR PASCAL ListBoxWndProc3d(HWND hwnd,
  492.                                             UINT wm,
  493.                                             WPARAM wParam,
  494.                                             LPARAM lParam)
  495. {
  496.     return SharedListWndProc(hwnd, wm, wParam, lParam, ctList);
  497. }
  498.  
  499. /*******************************************************************
  500.     Function: StaticWndProc3d(
  501.  
  502.        Description:
  503.  
  504. ********************************************************************/
  505.  
  506. LRESULT _loadds FAR PASCAL StaticWndProc3d(HWND hwnd,
  507.                                            UINT wm,
  508.                                            WPARAM wParam,
  509.                                            LPARAM lParam)
  510. {
  511.     HDC hdc;
  512.     PAINTSTRUCT ps;
  513.  
  514.     switch (wm)
  515.         {
  516.     case WM_PAINT:
  517.         if ((hdc = (HDC) wParam) == NULL)
  518.             {
  519.             hdc = BeginPaint(hwnd, &ps);
  520.             ClipCtlDc(hwnd, hdc);
  521.             }
  522.         StaticPaint(hwnd, hdc);
  523.         if (wParam == NULL)
  524.             EndPaint(hwnd, &ps);
  525.         return 0L;
  526.     case WM_ENABLE:
  527.         hdc = GetDC(hwnd);
  528.         ClipCtlDc(hwnd, hdc);
  529.         StaticPaint(hwnd, hdc);
  530.         ReleaseDC(hwnd, hdc);
  531.         return 0L;
  532.         }
  533.     return CallWindowProc(wndprocStatic, hwnd, wm, wParam, lParam);
  534.  
  535. }
  536.  
  537.  
  538. /*******************************************************************
  539.     Function: ComboBoxWndProc3d(
  540.  
  541.        Description:
  542.  
  543. ********************************************************************/
  544.  
  545. LRESULT _loadds FAR PASCAL ComboBoxWndProc3d(HWND hwnd,
  546.                                              UINT wm,
  547.                                              WPARAM wParam,
  548.                                              LPARAM lParam)
  549. {
  550.    LRESULT lRes;
  551.     lRes =  ShareEditComboWndProc3d(hwnd,
  552.                                    wm,
  553.                                    wParam,
  554.                                    lParam,
  555.                                    ctCombo);
  556.  
  557.  
  558.    
  559.    if (wm == WM_CREATE)
  560.    {
  561.       if (!ComboCreate(hwnd, (CREATESTRUCT FAR *)lParam))
  562.          SetWindowLong(hwnd,
  563.                        GWL_WNDPROC,
  564.                        (LONG)wndprocComboBox);
  565.    }
  566.  
  567.    return lRes;
  568.  
  569. }
  570.  
  571.  
  572. /*******************************************************************
  573.     Function: DialogProc3d(
  574.  
  575.        Description:
  576.  
  577. ********************************************************************/
  578.  
  579. LRESULT _loadds FAR PASCAL DialogProc3d(HWND hwnd,
  580.                                  UINT wm,
  581.                                  WPARAM wParam,
  582.                                  LPARAM lParam)
  583. {
  584.     HBRUSH hbrush;
  585.  
  586.     switch (wm)
  587.     {
  588.        case WM_CTLCOLOR:
  589.            hbrush = Ctl3dCtlColor((HDC)wParam, lParam);
  590.            if (hbrush != (HBRUSH)FALSE)
  591.                return (LRESULT)hbrush;
  592.            break;
  593.     }
  594.     
  595.     return CallWindowProc((WNDPROC)dlgprocUty, hwnd, wm, wParam, lParam);
  596. }
  597.  
  598.  
  599.  
  600.  
  601. /*******************************************************************
  602.     Function: RegisterClasses
  603.  
  604.        Description:
  605.  
  606. ********************************************************************/
  607.  
  608. BOOL RegisterClasses(HINSTANCE hInstance)
  609. {
  610.  
  611.    WNDCLASS wc;
  612.    //Edit
  613.    if (!GetClassInfo(NULL, "Edit", &wc))
  614.       return FALSE;
  615.  
  616.    wndprocEdit = wc.lpfnWndProc;
  617.  
  618.    wc.style |= CS_GLOBALCLASS;
  619.    wc.lpfnWndProc = EditWndProc3d;
  620.    wc.hInstance = hInstance;
  621.    wc.lpszClassName   = szEditClass;
  622.  
  623.    if (!RegisterClass(&wc))
  624.       return FALSE;
  625.  
  626.    //button
  627.    if (!GetClassInfo(NULL, "Button", &wc))
  628.       return FALSE;
  629.  
  630.    wndprocButton = wc.lpfnWndProc;
  631.  
  632.    wc.style |= CS_GLOBALCLASS;
  633.    wc.lpfnWndProc = ButtonWndProc3d;
  634.    wc.hInstance = hInstance;
  635.    wc.lpszClassName   = szButtonClass;
  636.  
  637.    if (!RegisterClass(&wc))
  638.       return FALSE;
  639.  
  640.    //listbox
  641.    if (!GetClassInfo(NULL, "Listbox", &wc))
  642.       return FALSE;
  643.  
  644.    wndprocListBox = wc.lpfnWndProc;
  645.  
  646.    wc.style |= CS_GLOBALCLASS;
  647.    wc.lpfnWndProc = ListBoxWndProc3d;
  648.    wc.hInstance = hInstance;
  649.    wc.lpszClassName   = szListBoxClass;
  650.  
  651.    if (!RegisterClass(&wc))
  652.       return FALSE;
  653.  
  654.    //Static
  655.    if (!GetClassInfo(NULL, "Static", &wc))
  656.       return FALSE;
  657.  
  658.    wndprocStatic = wc.lpfnWndProc;
  659.  
  660.    wc.style |= CS_GLOBALCLASS;
  661.    wc.lpfnWndProc = StaticWndProc3d;
  662.    wc.hInstance = hInstance;
  663.    wc.lpszClassName   = szStaticClass;
  664.  
  665.    if (!RegisterClass(&wc))
  666.       return FALSE;
  667.  
  668.  
  669.    //Combobox
  670.    if (!GetClassInfo(NULL, "ComboBox", &wc))
  671.       return FALSE;
  672.  
  673.    wndprocComboBox = wc.lpfnWndProc;
  674.  
  675.    wc.style |= CS_GLOBALCLASS;
  676.    wc.lpfnWndProc = ComboBoxWndProc3d;
  677.    wc.hInstance = hInstance;
  678.    wc.lpszClassName   = szComboBoxClass;
  679.  
  680.    if (!RegisterClass(&wc))
  681.       return FALSE;
  682.  
  683.  
  684.    //dialog class
  685.    if (!GetClassInfo(NULL, WC_DIALOG, &wc))
  686.       return FALSE;
  687.  
  688.    dlgprocUty = (DLGPROC)wc.lpfnWndProc;
  689.  
  690.    wc.style |= CS_GLOBALCLASS;
  691.    wc.lpfnWndProc = DialogProc3d;
  692.    wc.hInstance = hInstance;
  693.    wc.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
  694.    wc.lpszClassName   = szDialogClass;
  695.  
  696.    if (!RegisterClass(&wc))
  697.       return FALSE;
  698.  
  699.  
  700.    return TRUE;
  701.  
  702.  
  703.  
  704. }
  705. /*******************************************************************
  706.     Function: UtyCtlGetInstance();
  707.  
  708.        Description:
  709.  
  710. ********************************************************************/
  711.  
  712. HINSTANCE FAR PASCAL _export UtyCtlGetInstance()
  713. {
  714.    return hinstLib;
  715. }
  716. /*******************************************************************
  717.     Function: UtyCtlGetTemplate
  718.  
  719.        Description:  Returns the template name for common dialogs
  720.  
  721. ********************************************************************/
  722.  
  723. PSZ FAR PASCAL _export UtyCtlGetTemplate(SHORT sTempId)
  724. {
  725.    PSZ pszRet;
  726.  
  727.    switch(sTempId)
  728.    {
  729.       case UTY3DTEMP_OPENSAVE:
  730.          pszRet = "Uty3D_Open";
  731.          break;      
  732.       case UTY3DTEMP_COLOR:
  733.          pszRet = "Uty3D_Color";
  734.          break;      
  735.       case UTY3DTEMP_FONT:         
  736.          pszRet = "Uty3D_Font";
  737.          break;
  738.       case UTY3DTEMP_PRINT:
  739.          pszRet = "Uty3D_Print";
  740.          break;
  741.       case UTY3DTEMP_PRINTSTUP:
  742.          pszRet = "Uty3D_Prntstup";
  743.          break;
  744.       case UTY3DTEMP_FIND:
  745.          pszRet = "Uty3D_Find";
  746.          break;
  747.       case UTY3DTEMP_REPLACE:
  748.          pszRet = "Uty3D_Replace";
  749.          break;
  750.       default:
  751.          pszRet = NULL;
  752.          break;
  753.    }
  754.  
  755.    return pszRet;
  756.  
  757. }
  758.  
  759. /*******************************************************************
  760.     Function: UtyCtlWMCtlColor(
  761.  
  762.        Description:
  763.  
  764. ********************************************************************/
  765.  
  766. HBRUSH FAR PASCAL _export UtyCtlWMCtlColor(UINT ,
  767.                                            WPARAM wParam,
  768.                                            LPARAM lParam)
  769. {
  770. #ifdef WIN32
  771.     Assert(WM_CTLCOLORMSGBOX < WM_CTLCOLORBTN);
  772.     Assert(WM_CTLCOLOREDIT < WM_CTLCOLORBTN);
  773.     Assert(WM_CTLCOLORLISTBOX < WM_CTLCOLORBTN);
  774.     if(f3dDialogs)
  775.         {
  776.         if (wm >= WM_CTLCOLORLISTBOX)
  777.             {
  778.             if (wm == WM_CTLCOLORLISTBOX &&
  779.                 (GetWindow((HWND) lParam, GW_CHILD) == NULL ||
  780.                 (GetWindowLong((HWND) lParam, GWL_STYLE) & 0x03) == CBS_DROPDOWNLIST))
  781.                 {
  782.                 // if it doesn't have a child then it must be a list box
  783.                 // don't do brush stuff for drop down lists or else
  784.                 // it draws funny grey inside the edit rect
  785.                 return (HBRUSH) fFalse;
  786.                 }
  787.             SetTextColor((HDC) wParam, clrt.rgcv[icvBtnText]);
  788.             SetBkColor((HDC) wParam, clrt.rgcv[icvBtnFace]);
  789.                 return brt.mpicvhbr[icvBtnFace];
  790.             }
  791.         }
  792.     return (HBRUSH) fFalse;
  793. #else
  794.     return Ctl3dCtlColor((HDC)wParam, lParam);
  795. #endif
  796.  
  797. }
  798.  
  799. /*******************************************************************
  800.     Function: UtyCtlGetVersion()
  801.  
  802.        Description:
  803.  
  804. ********************************************************************/
  805.  
  806. USHORT FAR PASCAL _export UtyCtlGetVersion(void)
  807. {
  808.    return 0x0100;
  809. }
  810.  
  811. /*
  812. HANDLE CALLBACK ColorBtnInfo( void )          //  Provide info to dialog editor
  813. {
  814.    HANDLE hCtlInfo;
  815.    LPCTLINFO   lpCtlInfo;
  816.  
  817.    hCtlInfo = GlobalAlloc( GHND, (DWORD)sizeof(CTLINFO) );
  818.    if( hCtlInfo )
  819.    {
  820.       lpCtlInfo = (LPCTLINFO)GlobalLock( hCtlInfo );
  821.       if( lpCtlInfo )
  822.       {
  823.          lpCtlInfo->wVersion = 100;                  //  Generic version number
  824.          lpCtlInfo->wCtlTypes = 1;                     //  Single control, here
  825.  
  826.          lstrcpy( lpCtlInfo->szClass, CLASSNAME ); //  Use class name for class
  827.          lstrcpy( lpCtlInfo->szTitle, CLASSNAME );           //  and title text
  828.  
  829.  
  830.          lpCtlInfo->Type[ 0 ].wType = 0;
  831.          lpCtlInfo->Type[ 0 ].wWidth = 129;                        //  Set size
  832.          lpCtlInfo->Type[ 0 ].wHeight = 65;                //  Initialize flags
  833.          lpCtlInfo->Type[ 0 ].dwStyle = WS_CHILD | WS_TABSTOP;
  834.  
  835.          lstrcpy( lpCtlInfo->Type[ 0 ].szDescr, CLASSNAME );
  836.          GlobalUnlock( hCtlInfo );
  837.       }
  838.       else
  839.       {
  840.          GlobalFree( hCtlInfo );
  841.          hCtlInfo = NULL;
  842.       }
  843.    }
  844.    return( hCtlInfo );
  845. }
  846.  
  847.  
  848.  
  849.  
  850. BOOL CALLBACK ColorBtnStyle( hWnd, hCtlStyle, lpfnVerifyId, lpfnGetIdStr )
  851. HWND hWnd;
  852. HANDLE hCtlStyle;
  853. LPFNSTRTOID lpfnVerifyId;
  854. LPFNIDTOSTR lpfnGetIdStr;
  855. {
  856.    return( FALSE );                           //  No dialog...just return FALSE
  857. }
  858.  
  859.  
  860.  
  861.  
  862. WORD CALLBACK ColorBtnFlags( wFlags, lpszString, wMaxString )
  863. WORD wFlags;
  864. LPSTR lpszString;
  865. WORD wMaxString;
  866. {
  867.    lpszString[ 0 ] = NULL;       //  These strings get written to the .DLG file
  868.  
  869.    return( lstrlen( lpszString ) );         //  In effect, nothing gets written
  870. }
  871. */
  872.  
  873.  
  874.  
  875. LONG ShareEditComboWndProc3d(HWND hwnd,
  876.                              UINT wm,
  877.                              WPARAM wParam,
  878.                              LPARAM lParam,
  879.                              int ct)
  880. {
  881.     LONG l;
  882.  
  883.     l = CallWindowProc((ct == ctEdit) ? wndprocEdit : wndprocComboBox,
  884.                       hwnd,
  885.                       wm,
  886.                       wParam,
  887.                       lParam);
  888.  
  889.     switch(wm)
  890.         {
  891.     case WM_WINDOWPOSCHANGING:
  892.         if (verWindows >= ver31)
  893.             Inval3dCtl(hwnd, (WINDOWPOS FAR *) lParam);
  894.         break;
  895.  
  896.     case WM_PAINT:
  897.         if (ct != ctCombo || (GetWindowLong(hwnd, GWL_STYLE) & 0x0003) != CBS_SIMPLE)
  898.             ListEditPaint3d(hwnd, TRUE, ct);
  899.         break;
  900.         }
  901.     return l;
  902. }
  903.  
  904.  
  905.  
  906. void Inval3dCtl(HWND hwnd, WINDOWPOS FAR *lpwp)
  907.     {
  908.     RC rc;
  909.     HWND hwndParent;
  910.     LONG lStyle;
  911.  
  912.       GetWindowRect(hwnd, (LPRECT) &rc);
  913.     lStyle = GetWindowLong(hwnd, GWL_STYLE);
  914.     if (lStyle & WS_VISIBLE)
  915.         {
  916.         if (lpwp != NULL)
  917.             {
  918.             unsigned flags;
  919.  
  920.             // handle integral height listboxes (or any other control which 
  921.             // shrinks from the bottom)
  922.             flags = lpwp->flags;
  923.             if ((flags & (SWP_NOMOVE|SWP_NOSIZE)) == SWP_NOMOVE &&
  924.                 (lpwp->cx == (rc.xRight-rc.xLeft) && lpwp->cy <= (rc.yBot-rc.yTop)))
  925.                 rc.yTop = rc.yTop+lpwp->cy+1;        // +1 to offset InflateRect
  926.             }
  927.         InflateRect((LPRECT) &rc, 1, 1);
  928.         hwndParent = GetParent(hwnd);
  929.         ScreenToClient(hwndParent, (LPPOINT) &rc);
  930.             ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
  931.         if(lStyle & WS_VSCROLL)
  932.             rc.xRight ++;
  933.         InvalidateRect(hwndParent, (LPRECT) &rc, FALSE);
  934.         }
  935.     }
  936.  
  937.  
  938. void ListEditPaint3d(HWND hwnd, BOOL fEdit, int ct)
  939.     {
  940.     CTLID id;
  941.     RC rc;
  942.     HDC hdc;
  943.     HWND hwndParent;
  944.     LONG lStyle;
  945.     DR3 dr3;
  946.  
  947.     if(!((lStyle = GetWindowLong(hwnd, GWL_STYLE)) & WS_VISIBLE))
  948.         return;
  949.  
  950.     if (fEdit)
  951.         HideCaret(hwnd);
  952.  
  953.     GetWindowRect(hwnd, (LPRECT) &rc);            
  954.  
  955.     ScreenToClient(hwndParent = GetParent(hwnd), (LPPOINT) &rc);
  956.     ScreenToClient(hwndParent, ((LPPOINT) &rc)+1);
  957.  
  958.     hdc = GetDC(hwndParent);
  959.  
  960.     if(lStyle & WS_VSCROLL)
  961.         dr3 = dr3All & ~dr3Right;
  962.     else
  963.         dr3 = dr3All; 
  964.     // don't draw the top if it's a listbox of a simple combo
  965.  
  966.     id = GetControlId(hwnd);
  967.     if (id == (1000 + fEdit))
  968.         {
  969.         char szClass[20];
  970.  
  971.         GetClassName(hwndParent, szClass, sizeof(szClass));
  972.         if (!lstrcmp(szClass, szComboBoxClass))
  973.             {
  974.             if (fEdit)
  975.                 {
  976.                 RC rcList;
  977.                 HWND hwndList;
  978.                 if ((GetWindowLong(hwndParent, GWL_STYLE) & 0x0003) == CBS_SIMPLE)
  979.                     {
  980.                     dr3 &= ~dr3Bot;
  981.             
  982.                     hwndList = GetWindow(hwndParent, GW_CHILD);
  983.                     GetWindowRect(hwndList, (LPRECT) &rcList);
  984.             
  985.                     // Some ugly stuff goin' on here!
  986.                     rc.xRight -= rcList.xRight-rcList.xLeft;
  987.                     DrawInsetRect3d(hdc, &rc, dr3Bot|dr3HackBotRight);
  988.                     rc.xRight += rcList.xRight-rcList.xLeft;        
  989.                     }
  990.                 }
  991.             else
  992.                 {
  993.                 rc.yTop++;
  994.                 dr3 &= ~dr3Top;
  995.                 }
  996.             }
  997.         }
  998.  
  999.     DrawInsetRect3d(hdc, &rc, dr3);
  1000.  
  1001.     if ((ct == ctCombo && (lStyle & 0x003) == CBS_DROPDOWNLIST))
  1002.         {
  1003.         rc.xLeft = rc.xRight - GetSystemMetrics(SM_CXVSCROLL);
  1004.         DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Right|dr3Bot);
  1005.         }
  1006.     else if (lStyle & WS_VSCROLL)
  1007.          {
  1008.         rc.xRight++;
  1009.         DrawRec3d(hdc, &rc, icvForceWhite, icvForceWhite, dr3Right);
  1010.         rc.xRight--;
  1011.         rc.xLeft = rc.xRight - GetSystemMetrics(SM_CXVSCROLL);
  1012.         DrawRec3d(hdc, &rc, icvWindowFrame, icvWindowFrame, dr3Bot);
  1013.         }
  1014.  
  1015.     ReleaseDC(hwndParent, hdc);
  1016.     if (fEdit)
  1017.         ShowCaret(hwnd);            
  1018.     }
  1019.  
  1020.  
  1021. /*******************************************************************
  1022.     Function: DrawInsetRect3d(
  1023.  
  1024.        Description:
  1025.  
  1026. ********************************************************************/
  1027.  
  1028. void DrawInsetRect3d(HDC hdc, 
  1029.                      RC FAR *prc, 
  1030.                      DR3 dr3)
  1031.     {
  1032.     RC rc;
  1033.  
  1034.     rc = *prc;
  1035.     DrawRec3d(hdc, &rc, icvWindowFrame, icvForceLTGray, dr3 & dr3All);
  1036.     rc.xLeft--;
  1037.     rc.yTop--;
  1038.     rc.xRight++;
  1039.     rc.yBot++;
  1040.     DrawRec3d(hdc, &rc, icvForceDKGray, icvForceWhite, dr3);
  1041.     }
  1042.  
  1043. /*******************************************************************
  1044.     Function: DrawRec3d(
  1045.  
  1046.        Description:
  1047.  
  1048. ********************************************************************/
  1049.  
  1050. void DrawRec3d(HDC hdc,
  1051.                RC FAR *lprc, 
  1052.                ICV icvUL, 
  1053.                ICV icvLR, 
  1054.                DR3 dr3)
  1055.     {
  1056.     COLORREF cvSav;
  1057.     RC rc;
  1058.  
  1059.     cvSav = SetBkColor(hdc, clrt.rgcv[icvUL]);
  1060.  
  1061.     // top
  1062.     rc = *lprc;
  1063.     rc.yBot = rc.yTop+1;
  1064.     if (dr3 & dr3Top)
  1065.         ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc, 
  1066.             (char far *) NULL, 0, (int far *) NULL);
  1067.  
  1068.     // left
  1069.     rc.yBot = lprc->yBot;
  1070.     rc.xRight = rc.xLeft+1;
  1071.     if (dr3 & dr3Left)
  1072.         ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc, 
  1073.             (char far *) NULL, 0, (int far *) NULL);
  1074.  
  1075.     if (icvUL != icvLR)
  1076.         SetBkColor(hdc, clrt.rgcv[icvLR]);
  1077.  
  1078.     // right
  1079.     rc.xRight = lprc->xRight;
  1080.     rc.xLeft = rc.xRight-1;
  1081.     if (dr3 & dr3Right)
  1082.         ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc, 
  1083.             (char far *) NULL, 0, (int far *) NULL);
  1084.  
  1085.     // bot
  1086.     if (dr3 & dr3Bot)
  1087.         {
  1088.         rc.xLeft = lprc->xLeft;
  1089.         rc.yTop = rc.yBot-1;
  1090.         if (dr3 & dr3HackBotRight)
  1091.             rc.xRight -=2;
  1092.         ExtTextOut(hdc, 0, 0, ETO_OPAQUE, (LPRECT) &rc, 
  1093.             (char far *) NULL, 0, (int far *) NULL);
  1094.         }
  1095.  
  1096.     SetBkColor(hdc, cvSav);
  1097.     }
  1098.  
  1099.  
  1100. /*******************************************************************
  1101.     Function: UtyCtlColorChange
  1102.  
  1103.        Description:
  1104.  
  1105. ********************************************************************/
  1106.  
  1107. BOOL FAR PASCAL _export UtyCtlColorChange(void)
  1108.     {
  1109.     ICV icv;
  1110.     CLRT clrtNew;
  1111.     HBITMAP hbmpCheckboxesNew;
  1112.     BRT brtNew;
  1113.  
  1114.     for (icv = 0; icv < icvSysMax; icv++)
  1115.         clrtNew.rgcv[icv] = GetSysColor(mpicvSysColor[icv]);
  1116.  
  1117.    //add forced colors to the table..
  1118.    clrtNew.rgcv[icvForceBlack] = RGB(0,0,0);
  1119.    clrtNew.rgcv[icvForceLTGray] = RGB(192,192,192);
  1120.    clrtNew.rgcv[icvForceDKGray] = RGB(128,128,128);
  1121.    clrtNew.rgcv[icvForceWhite] = RGB(255,255,255);
  1122.  
  1123.     if (verWindows == ver30)
  1124.         clrtNew.rgcv[icvBtnHilite] = RGB(0xff, 0xff, 0xff);
  1125.  
  1126.     if (clrtNew.rgcv[icvGrayText] == 0L || clrtNew.rgcv[icvGrayText] == clrtNew.rgcv[icvBtnFace])
  1127.         clrtNew.rgcv[icvGrayText] = RGB(0x80, 0x80, 0x80);
  1128.     if (clrtNew.rgcv[icvGrayText] == clrtNew.rgcv[icvBtnFace])
  1129.         clrtNew.rgcv[icvGrayText] = 0L;
  1130.  
  1131.     if (MEMICMP(&clrt, &clrtNew, sizeof(CLRT)))
  1132.         {
  1133.          hbmpCheckboxesNew = LoadUIBitmap(hinstLib, "D3", 
  1134.             RGB(0,0,0),       //clrtNew.rgcv[icvWindowText],
  1135.             RGB(192,192,192), //clrtNew.rgcv[icvBtnFace],
  1136.             RGB(128,128,128), //clrtNew.rgcv[icvBtnShadow],
  1137.             RGB(255,255,255), //clrtNew.rgcv[icvBtnHilite],
  1138.             RGB(255,255,255), //clrtNew.rgcv[icvWindow],
  1139.             clrtNew.rgcv[icvWindowFrame]);
  1140.  
  1141.         for (icv = 0; icv < icvSysBrushMax; icv++)
  1142.             brtNew.mpicvhbr[icv] = CreateSolidBrush(clrtNew.rgcv[icv]);
  1143.  
  1144.  
  1145.       brtNew.mpicvhbr[icvBRBack] = CreateSolidBrush(RGB(192,192,192));
  1146.  
  1147.       brtNew.mpicvhbr[icvBRLTGray] = CreateSolidBrush(RGB(192,192,192));
  1148.  
  1149.         for (icv = 0; icv < icvBrushMax; icv++)
  1150.             if (brtNew.mpicvhbr[icv] == NULL)
  1151.                 goto OOM;
  1152.  
  1153.         if(hbmpCheckboxesNew != NULL)
  1154.             {
  1155.             DeleteObjects();
  1156.             brt = brtNew;
  1157.             clrt = clrtNew;
  1158.             hbmpCheckboxes = hbmpCheckboxesNew;
  1159.             return TRUE;
  1160.             }
  1161.         else
  1162.             {
  1163. OOM:
  1164.             for (icv = 0; icv < icvBrushMax; icv++)
  1165.                 DeleteBrushNull((HBRUSH FAR *)&brtNew.mpicvhbr[icv]);
  1166.             DeleteBrushNull((HBRUSH FAR *)&hbmpCheckboxesNew);
  1167.             return FALSE;
  1168.             }
  1169.         }
  1170.     return TRUE;
  1171.     }
  1172.  
  1173. /*******************************************************************
  1174.     Function: UtyCtlMakeLink()
  1175.  
  1176.        Description:  This function is only here for a program
  1177.        to call to force the linker to link in the dll.
  1178.  
  1179. ********************************************************************/
  1180.  
  1181. void FAR PASCAL _export UtyCtlMakeLink(void)
  1182. {
  1183. }
  1184.  
  1185.  
  1186. /*******************************************************************
  1187.     Function: DeleteBrushNull(
  1188.  
  1189.        Description:
  1190.  
  1191. ********************************************************************/
  1192.  
  1193. VOID DeleteBrushNull(HBRUSH FAR *ph)
  1194.     {
  1195.     if (*ph != NULL)
  1196.         {
  1197.         DeleteObject(*ph);
  1198.         *ph = NULL;
  1199.         }
  1200.     }
  1201.  
  1202. /*******************************************************************
  1203.     Function: DeleteObjects(
  1204.  
  1205.        Description:
  1206.  
  1207. ********************************************************************/
  1208.  
  1209. VOID DeleteObjects(VOID)
  1210.     {
  1211.     int icv;
  1212.  
  1213.     for(icv = 0; icv < icvBrushMax; icv++)
  1214.         DeleteBrushNull((HBRUSH FAR *)&brt.mpicvhbr[icv]);
  1215.     DeleteBrushNull((HBRUSH FAR *)&hbmpCheckboxes);
  1216.  
  1217.     }
  1218.  
  1219.  
  1220. /*******************************************************************
  1221.     Function: BtnPaint(
  1222.  
  1223.        Description:
  1224.  
  1225. ********************************************************************/
  1226.  
  1227. VOID BtnPaint(HWND hwnd,
  1228.               HDC hdc,
  1229.               int bp)
  1230.     {
  1231.     RC rc;
  1232.     RC rcClient;
  1233.     HFONT hfont;
  1234.     int bs;
  1235.     int bf;
  1236.     HBRUSH hbrBtn;
  1237.     HWND hwndParent;
  1238.     int xBtnBmp;
  1239.     int yBtnBmp;
  1240.     HBITMAP hbmpSav;
  1241.     HDC hdcMem;
  1242.     char szTitle[256];
  1243.     int cch;
  1244.     BOOL fEnabled;
  1245.  
  1246.     bs = ((int) GetWindowLong(hwnd, GWL_STYLE)) & 0x1F;
  1247.     hwndParent = GetParent(hwnd);
  1248.     SetBkMode(hdc, OPAQUE);
  1249.     GetClientRect(hwnd, (LPRECT)&rcClient);
  1250.     rc = rcClient;
  1251.     if((hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L)) != NULL)
  1252.         hfont = (HFONT)SelectObject(hdc, hfont);
  1253.  
  1254.     hbrBtn = SEND_COLOR_BUTTON_MESSAGE(hwndParent, hwnd, hdc);
  1255.     hbrBtn = (HBRUSH)SelectObject(hdc, hbrBtn);
  1256.     IntersectClipRect(hdc, rc.xLeft, rc.yTop, rc.xRight, rc.yBot);
  1257.     if(bp & bpBkgnd && (bs != BS_GROUPBOX))
  1258.         PatBlt(hdc, rc.xLeft, rc.yTop, rc.xRight-rc.xLeft, rc.yBot-rc.yTop, PATCOPY);
  1259.  
  1260.     fEnabled = IsWindowEnabled(hwnd);
  1261.     bf = (int) SendMessage(hwnd, BM_GETSTATE, 0, 0L);
  1262.     yBtnBmp = 0;
  1263.     xBtnBmp = (((bf&BFCHECK) != 0) | ((bf&BFSTATE) >> 1)) * 14;
  1264.     if (!fEnabled)
  1265.         xBtnBmp += 14*(2+((bf&BFCHECK) != 0));
  1266.     if(bp & (bpText|bpFocus) || 
  1267.             bs == BS_PUSHBUTTON || bs == BS_DEFPUSHBUTTON)
  1268.         cch = GetWindowText(hwnd, szTitle, sizeof(szTitle));
  1269.     switch(bs)
  1270.         {
  1271. #ifdef DEBUG
  1272.         default:
  1273.             Assert(fFalse);
  1274.             break;
  1275. #endif
  1276.         case BS_PUSHBUTTON:
  1277.         case BS_DEFPUSHBUTTON:
  1278.             DrawPushButton(hwnd, hdc, &rcClient, szTitle, cch, bs, bf & BFSTATE);
  1279.             break;
  1280.  
  1281.         case BS_RADIOBUTTON:
  1282.         case BS_AUTORADIOBUTTON:
  1283.             yBtnBmp = 13;
  1284.             goto DrawBtn;
  1285.         case BS_3STATE:
  1286.         case BS_AUTO3STATE:
  1287.             Assert((BFSTATE >> 1) == 2);
  1288.             if((bf & BFCHECK) == 2)
  1289.                 yBtnBmp = 26;
  1290.             // fall through
  1291.         case BS_CHECKBOX:
  1292.         case BS_AUTOCHECKBOX:
  1293. DrawBtn:
  1294.             if(bp & bpCheck)
  1295.                 {
  1296.                 hdcMem = CreateCompatibleDC(hdc);
  1297.                 if(hdcMem != NULL)
  1298.                     {
  1299.                     hbmpSav = (HBITMAP)SelectObject(hdcMem, hbmpCheckboxes);
  1300.                     if(hbmpSav != NULL)
  1301.                         {
  1302.                         BitBlt(hdc, rc.xLeft, rc.yTop+(rc.yBot-rc.yTop-13)/2,
  1303.                             14, 13, hdcMem, xBtnBmp, yBtnBmp, SRCCOPY);
  1304.                             SelectObject(hdcMem, hbmpSav);
  1305.                         }
  1306.                     DeleteDC(hdcMem);
  1307.                     }
  1308.                 }
  1309.             if(bp & bpText)
  1310.                 {
  1311.                 // BUG! this assumes we have only 1 hbm3dCheck type
  1312.                 rc.xLeft = rcClient.xLeft + 14+4;
  1313. //                MyDrawText(hwnd, hdc, (LPSTR) szTitle, cch, &rc, DT_VCENTER|DT_LEFT|DT_SINGLELINE);
  1314.                 if(!fEnabled)
  1315.                     SetTextColor(hdc, clrt.rgcv[icvGrayText]);
  1316.                 DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_VCENTER|DT_LEFT|DT_SINGLELINE);
  1317.                 }
  1318.             if(bp & bpFocus)
  1319.                 {
  1320.                 int dx;
  1321.                 int dy;
  1322.  
  1323.                 rc.xLeft = rcClient.xLeft + 14+4;
  1324.  
  1325.                 MyGetTextExtent(hdc, szTitle, &dx, &dy);
  1326.                 rc.yTop = (rc.yBot-rc.yTop-dy)/2;
  1327.                 rc.yBot = rc.yTop+dy;
  1328.                 rc.xRight = rc.xLeft + dx;
  1329.  
  1330.                 InflateRect((LPRECT) &rc, 1, 1);
  1331.                 IntersectRect((LPRECT) &rc, (LPRECT) &rc, (LPRECT) &rcClient);
  1332.                 DrawFocusRect(hdc, (LPRECT) &rc);
  1333.                 }
  1334.             break;
  1335.         case BS_GROUPBOX:
  1336.             if(bp & (bpText|bpCheck))
  1337.                 {
  1338.                 int dy;
  1339.  
  1340.                 dy = DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_CALCRECT|DT_LEFT|DT_SINGLELINE);
  1341.  
  1342.                 rcClient.yTop += dy/2;
  1343.                 rcClient.xRight--;
  1344.                 rcClient.yBot--;
  1345.                 //DrawRec3d(hdc, &rcClient, icvBtnShadow, icvBtnShadow, dr3All);
  1346.                 DrawRec3d(hdc, &rcClient, icvForceDKGray, icvForceDKGray, dr3All);
  1347.                 OffsetRect((LPRECT) &rcClient, 1, 1);
  1348.                 //DrawRec3d(hdc, &rcClient, icvBtnHilite, icvBtnHilite, dr3All);
  1349.                 DrawRec3d(hdc, &rcClient, icvForceWhite, icvForceWhite, dr3All);
  1350.                 rc.xLeft += 4;
  1351.                 rc.xRight += 4;
  1352.                 rc.yBot = rc.yTop+dy;
  1353.  
  1354.                 if(!fEnabled)
  1355.                     SetTextColor(hdc, clrt.rgcv[icvGrayText]);
  1356.                 DrawText(hdc, szTitle, cch, (LPRECT) &rc, DT_LEFT|DT_SINGLELINE);
  1357.                 }
  1358.             break;
  1359.         }
  1360.  
  1361.     SelectObject(hdc, hbrBtn);
  1362.     if(hfont != NULL)
  1363.         SelectObject(hdc, hfont);
  1364.     }
  1365.  
  1366.  
  1367. /*******************************************************************
  1368.     Function: DrawPushButton(
  1369.  
  1370.        Description:
  1371.  
  1372. ********************************************************************/
  1373.  
  1374. VOID DrawPushButton(HWND hwnd,
  1375.                     HDC hdc,
  1376.                     RC FAR *lprc,
  1377.                     LPSTR lpch,
  1378.                     int cch,
  1379.                     WORD bs,
  1380.                     BOOL fDown)
  1381.     {
  1382.     //int dxyBrdr;
  1383.     int dxyShadow;
  1384.     HBRUSH hbrSav;
  1385.     RC rcInside;
  1386.     int dy;
  1387.     int dx;
  1388.     //LONG dwExt;
  1389.  
  1390.       rcInside = *lprc;
  1391.  
  1392.     if (!(grbitStyle & bitFCoolButtons))
  1393.         {
  1394.         DrawRec3d(hdc, lprc, icvWindowFrame, icvWindowFrame, dr3All);
  1395.         InflateRect((LPRECT) &rcInside, -1, -1);
  1396.         if (bs == LOWORD(BS_DEFPUSHBUTTON) && IsWindowEnabled(hwnd))
  1397.             {
  1398.             //dxyBrdr = 2;
  1399.             DrawRec3d(hdc, &rcInside, icvWindowFrame, icvWindowFrame, dr3All);
  1400.             InflateRect((LPRECT) &rcInside, -1, -1);
  1401.             }
  1402.         //else
  1403.         //    dxyBrdr = 1;
  1404.  
  1405.         // Notch the corners
  1406.         PatBlt(hdc, lprc->xLeft, lprc->yTop, dxBorder, dyBorder, PATCOPY);
  1407.         /* Top xRight corner */
  1408.         PatBlt(hdc, lprc->xRight - dxBorder, lprc->yTop, dxBorder, dyBorder, PATCOPY);
  1409.         /* yBot xLeft corner */
  1410.         PatBlt(hdc, lprc->xLeft, lprc->yBot - dyBorder, dxBorder, dyBorder, PATCOPY);
  1411.         /* yBot xRight corner */
  1412.         PatBlt(hdc, lprc->xRight - dxBorder, lprc->yBot - dyBorder, dxBorder, dyBorder, PATCOPY);
  1413.         dxyShadow = 1 + !fDown;
  1414.         }
  1415.     else
  1416.         dxyShadow = 1;
  1417.  
  1418.     // draw upper left hilite/shadow
  1419.  
  1420.     if (fDown)
  1421.         hbrSav = (HBRUSH)SelectObject(hdc, brt.mpicvhbr[icvBtnShadow]);
  1422.     else
  1423.         hbrSav = (HBRUSH)SelectObject(hdc, brt.mpicvhbr[icvBtnHilite]);
  1424.  
  1425.     PatBlt(hdc, rcInside.xLeft, rcInside.yTop, dxyShadow,
  1426.         (rcInside.yBot - rcInside.yTop), PATCOPY);
  1427.     PatBlt(hdc, rcInside.xLeft, rcInside.yTop,
  1428.         (rcInside.xRight - rcInside.xLeft), dxyShadow, PATCOPY);
  1429.  
  1430.     // draw lower right shadow (only if not down)
  1431.     if (!fDown || (grbitStyle & bitFCoolButtons))
  1432.         {
  1433.         int i;
  1434.  
  1435.         if (fDown)
  1436.             SelectObject(hdc, brt.mpicvhbr[icvBtnHilite]);
  1437.         else
  1438.             SelectObject(hdc, brt.mpicvhbr[icvBtnShadow]);
  1439.         rcInside.yBot--;
  1440.         rcInside.xRight--;
  1441.  
  1442.         for (i = 0; i < dxyShadow; i++)
  1443.             {
  1444.          PatBlt(hdc, rcInside.xLeft, rcInside.yBot,
  1445.                 rcInside.xRight - rcInside.xLeft + dxBorder, dyBorder, 
  1446.                 PATCOPY);
  1447.             PatBlt(hdc, rcInside.xRight, rcInside.yTop, dxBorder,
  1448.                 rcInside.yBot - rcInside.yTop, PATCOPY);
  1449.             if (i < dxyShadow-1)
  1450.                 InflateRect((LPRECT) &rcInside, -dxBorder, -dyBorder);
  1451.             }
  1452.         }
  1453.     // draw the button face
  1454.  
  1455.     rcInside.xLeft++;
  1456.     rcInside.yTop++;
  1457.  
  1458.     SelectObject(hdc, brt.mpicvhbr[icvBtnFace]);
  1459.     PatBlt(hdc, rcInside.xLeft, rcInside.yTop, rcInside.xRight-rcInside.xLeft,
  1460.         rcInside.yBot - rcInside.yTop, PATCOPY);
  1461.  
  1462.     // Draw the durned text
  1463.  
  1464.     if(!IsWindowEnabled(hwnd))
  1465.         SetTextColor(hdc, clrt.rgcv[icvGrayText]);
  1466.     
  1467.     MyGetTextExtent(hdc, lpch, &dx, &dy);
  1468.     rcInside.yTop += (rcInside.yBot-rcInside.yTop-dy)/2;
  1469.     rcInside.xLeft += (rcInside.xRight-rcInside.xLeft-dx)/2;
  1470.     rcInside.yBot = rcInside.yTop+dy;
  1471.     rcInside.xRight = rcInside.xLeft+dx;
  1472.  
  1473.     if (fDown)
  1474.         {
  1475.         OffsetRect((LPRECT) &rcInside, 1, 1);
  1476.         }
  1477.  
  1478.     DrawText(hdc, lpch, cch, (LPRECT) &rcInside, DT_LEFT|DT_SINGLELINE);
  1479.     
  1480.     if (hwnd == GetFocus())
  1481.         {
  1482.         InflateRect((LPRECT) &rcInside, 1, 1);
  1483.         IntersectRect((LPRECT) &rcInside, (LPRECT) &rcInside, (LPRECT) lprc);
  1484.         DrawFocusRect(hdc, (LPRECT) &rcInside);
  1485.         }
  1486.  
  1487.     if (hbrSav)
  1488.         SelectObject(hdc, hbrSav);
  1489.     }
  1490.  
  1491.  
  1492. /*******************************************************************
  1493.     Function: MyGetTextExtent(
  1494.  
  1495.        Description:
  1496.  
  1497. ********************************************************************/
  1498.  
  1499. VOID MyGetTextExtent(HDC hdc,
  1500.                      LPSTR lpsz,
  1501.                      int FAR *lpdx,
  1502.                      int FAR *lpdy)
  1503.     {
  1504.     char FAR *lpch;
  1505.     char szT[256];
  1506.  
  1507.     lpch = szT;
  1508.     while(*lpsz != '\000')
  1509.         {
  1510.         if (*lpsz == '&')
  1511.             {
  1512.             lpsz++;
  1513.             if (*lpsz == '\000')
  1514.                 break;
  1515.             }
  1516.         *lpch++ = *lpsz++;
  1517.         }
  1518.     *lpch = '\000';
  1519. #ifdef WIN32
  1520.     {
  1521.     PT pt;
  1522.  
  1523.     GetTextExtentPoint(hdc, lpsz, strlen(szT), &pt);
  1524.     *lpdx = pt.x;
  1525.     *lpdy = pt.y;
  1526.     }
  1527. #else
  1528.     {
  1529.     long dwExt;
  1530.  
  1531.     dwExt = GetTextExtent(hdc, szT, lpch-(char far *)szT);
  1532.     *lpdx = LOWORD(dwExt);
  1533.     *lpdy = HIWORD(dwExt);
  1534.     }
  1535. #endif
  1536.     }
  1537.  
  1538. /*******************************************************************
  1539.     Function: Ctl3dCtlColor
  1540.  
  1541.        Description:
  1542.  
  1543. ********************************************************************/
  1544.  
  1545. HBRUSH FAR PASCAL Ctl3dCtlColor(HDC hdc,
  1546.                                 LONG lParam)
  1547.     {
  1548.     HWND hwndParent;
  1549. #ifdef WIN32
  1550.     return (HBRUSH) fFalse;
  1551. #else
  1552.     Assert(CTLCOLOR_MSGBOX < CTLCOLOR_BTN);
  1553.     Assert(CTLCOLOR_EDIT < CTLCOLOR_BTN);
  1554.     Assert(CTLCOLOR_LISTBOX < CTLCOLOR_BTN);
  1555.  
  1556.    
  1557.     if (HIWORD(lParam) >= CTLCOLOR_LISTBOX) //_EDIT & _MSGBOX fail here
  1558.         {
  1559.         if (HIWORD(lParam) == CTLCOLOR_LISTBOX &&
  1560.             (GetWindow((HWND)(LOWORD(lParam)), GW_CHILD) == NULL ||
  1561.             (GetWindowLong((HWND)(LOWORD(lParam)), GWL_STYLE) & 0x03) == CBS_DROPDOWNLIST))
  1562.             {
  1563.             // if it doesn't have a child then it must be a list box
  1564.             // don't do brush stuff for drop down lists or else
  1565.             // it draws funny grey inside the edit rect
  1566.             goto DefWP;
  1567.             }
  1568.       else if (HIWORD(lParam) == CTLCOLOR_SCROLLBAR)
  1569.          goto DefWP;
  1570.       else if (FUseWindowColors((HWND)(LOWORD(lParam)), HIWORD(lParam)) )
  1571.          {
  1572.             SetTextColor(hdc, clrt.rgcv[icvBtnText]);
  1573.            SetBkColor(hdc, clrt.rgcv[icvBtnFace]);
  1574.          return brt.mpicvhbr[icvBtnFace]; 
  1575.          }
  1576.       else
  1577.          {
  1578.          SetTextColor(hdc, clrt.rgcv[icvForceBlack]);
  1579.             SetBkColor(hdc, clrt.rgcv[icvForceLTGray]);
  1580.          return brt.mpicvhbr[icvBRBack];
  1581.          }
  1582.         }
  1583.         
  1584. DefWP:
  1585.     hwndParent = GetParent((HWND)(LOWORD(lParam)));
  1586.     if (hwndParent == NULL)
  1587.         return FALSE;
  1588.     return (HBRUSH)DefWindowProc(hwndParent, WM_CTLCOLOR, (WPARAM) hdc, (LONG) lParam);
  1589. #endif
  1590.     }
  1591.  
  1592.  
  1593. /*******************************************************************
  1594.     Function: FUseWindowColors(
  1595.  
  1596.        Description:
  1597.  
  1598. ********************************************************************/
  1599.  
  1600. BOOL FUseWindowColors(HWND hwnd,
  1601.                       int iType)
  1602. {
  1603.    int iStyle;
  1604.  
  1605.    if (iType == CTLCOLOR_BTN)
  1606.    {
  1607.       iStyle = ((int)GetWindowLong(hwnd, GWL_STYLE)) & 0x1f;
  1608.  
  1609.       if (iStyle == BS_PUSHBUTTON || iStyle == BS_DEFPUSHBUTTON)
  1610.          return TRUE;
  1611.       else
  1612.          return FALSE;
  1613.    }
  1614.     
  1615.    return FALSE;
  1616.  
  1617.  
  1618. /*******************************************************************
  1619.     Function: SharedListWndProc(
  1620.  
  1621.        Description:
  1622.  
  1623. ********************************************************************/
  1624.  
  1625. LONG SharedListWndProc(HWND hwnd,
  1626.                        UINT wm,
  1627.                        WPARAM wParam,
  1628.                        LPARAM lParam,
  1629.                        unsigned ct)
  1630.     {
  1631.     LONG l;
  1632.     switch(wm)
  1633.         {
  1634.     case WM_WINDOWPOSCHANGING:
  1635.         if (verWindows >= ver31)
  1636.             Inval3dCtl(hwnd, (WINDOWPOS FAR *) lParam);
  1637.         break;
  1638.     case WM_PAINT:
  1639.         l = CallWindowProc(wndprocListBox, hwnd, wm, wParam, lParam);
  1640.         ListEditPaint3d(hwnd, FALSE, ct);
  1641.         return l;
  1642.        }
  1643.     return CallWindowProc(wndprocListBox, hwnd, wm, wParam, lParam);
  1644.     }
  1645.  
  1646.  
  1647. /*******************************************************************
  1648.     Function: ClipCtlDc(
  1649.  
  1650.        Description:
  1651.  
  1652. ********************************************************************/
  1653.  
  1654. VOID ClipCtlDc(HWND hwnd,
  1655.                HDC hdc)
  1656. {
  1657.     RC rc;
  1658.  
  1659.     GetClientRect(hwnd, (LPRECT) &rc);
  1660.     IntersectClipRect(hdc, rc.xLeft, rc.yTop, rc.xRight, rc.yBot);
  1661. }
  1662.  
  1663. /*******************************************************************
  1664.     Function: StaticPaint(
  1665.  
  1666.        Description:
  1667.  
  1668. ********************************************************************/
  1669.  
  1670. void StaticPaint(HWND hwnd,
  1671.                  HDC hdc)
  1672. {
  1673.     LONG style;
  1674.     RC rc;
  1675.  
  1676.     style = GetWindowLong(hwnd, GWL_STYLE);
  1677.     if(!(style & WS_VISIBLE))
  1678.         return;
  1679.  
  1680.     GetClientRect(hwnd, (LPRECT) &rc);
  1681.     switch(style & 0x0f)
  1682.         {
  1683.     case SS_BLACKRECT:
  1684.     case SS_BLACKFRAME:        // Inset rect
  1685.       DrawRec3d(hdc, &rc, icvForceDKGray, icvForceWhite, dr3All);
  1686.         break;
  1687.     case SS_GRAYRECT:
  1688.     case SS_GRAYFRAME:
  1689.         rc.xLeft++;
  1690.         rc.yTop++;
  1691.         DrawRec3d(hdc, &rc, icvForceWhite, icvForceWhite, dr3All);
  1692.         OffsetRect((LPRECT) &rc, -1, -1);
  1693.         DrawRec3d(hdc, &rc, icvForceDKGray, icvForceDKGray, dr3All);
  1694.         break;
  1695.     case SS_WHITERECT:                // outset rect
  1696.     case SS_WHITEFRAME:
  1697.         DrawRec3d(hdc, &rc, icvForceWhite, icvForceDKGray, dr3All);
  1698.         break;
  1699.     case SS_LEFT:
  1700.     case SS_CENTER:
  1701.     case SS_RIGHT:
  1702.     case SS_LEFTNOWORDWRAP:
  1703.         {
  1704.         HFONT hfont;
  1705.         HBRUSH hbr;
  1706.  
  1707.         if((hfont = (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0L)) != NULL)
  1708.             hfont = (HFONT)SelectObject(hdc, hfont);
  1709.         SetBkMode(hdc, OPAQUE);
  1710.  
  1711.         if(( hbr = SEND_COLOR_STATIC_MESSAGE(GetParent(hwnd), hwnd, hdc)) != NULL)
  1712.             hbr = (HBRUSH)SelectObject(hdc, hbr);
  1713.  
  1714.         StaticPrint(hwnd, hdc, (RC FAR *)&rc, style);
  1715.  
  1716.         if (hfont != NULL)
  1717.             SelectObject(hdc, hfont);
  1718.  
  1719.         if (hbr != NULL)
  1720.             SelectObject(hdc, hbr);
  1721.         }
  1722.         break;
  1723.         }
  1724. }
  1725.  
  1726. /*******************************************************************
  1727.     Function: StaticPrint(
  1728.  
  1729.        Description:
  1730.  
  1731. ********************************************************************/
  1732.  
  1733. void StaticPrint(HWND hwnd,
  1734.                  HDC hdc,
  1735.                  RC FAR *lprc,
  1736.                  LONG style)
  1737. {
  1738.     WORD dt;
  1739.     LONG cv;
  1740. //    int cch;
  1741.     char szText[256];
  1742.  
  1743.     PatBlt(hdc, lprc->xLeft, lprc->yTop, lprc->xRight-lprc->xLeft, lprc->yBot-lprc->yTop, PATCOPY);
  1744.  
  1745.  
  1746. //    if ((cch = GetWindowText(hwnd, szText, sizeof(szText))) == 0)
  1747.     if ( GetWindowText(hwnd, szText, sizeof(szText)) == 0)
  1748.         return;
  1749.     
  1750.     if ((style & 0x000f) == SS_LEFTNOWORDWRAP)
  1751.         dt = DT_NOCLIP | DT_EXPANDTABS;
  1752.     else
  1753.         {
  1754.         dt = DT_NOCLIP | DT_EXPANDTABS | DT_WORDBREAK | ((style & 0x000f)-SS_LEFT);
  1755.         }
  1756.  
  1757.     if (style & SS_NOPREFIX)
  1758.         dt |= DT_NOPREFIX;
  1759.  
  1760.     if (style & WS_DISABLED)
  1761.         cv = SetTextColor(hdc, clrt.rgcv[icvGrayText]);
  1762.  
  1763.     DrawText(hdc, szText, -1, (LPRECT) lprc, dt);
  1764.  
  1765. //    MyDrawText(hwnd, hdc, (LPSTR) szText, cch, lprc, dt);
  1766.  
  1767.     if (style & WS_DISABLED)
  1768.         cv = SetTextColor(hdc, cv);
  1769. }
  1770.  
  1771. /*******************************************************************
  1772.     Function: ComboCreate(
  1773.  
  1774.        Description:
  1775.  
  1776. ********************************************************************/
  1777.  
  1778. BOOL ComboCreate(HWND hwndCombo,
  1779.                  CREATESTRUCT FAR *pcs)
  1780. {
  1781.  
  1782.     HWND hwndEdit;
  1783.     HWND hwndList;
  1784.  
  1785.    if ((pcs->style & 0x0003) == CBS_SIMPLE)
  1786.    {
  1787.           hwndList = GetWindow(hwndCombo, GW_CHILD);
  1788.         if (hwndList != NULL)
  1789.       {
  1790.          //subclass edit and list along with the combo for simple
  1791.          SetWindowLong(hwndList, 
  1792.                        GWL_WNDPROC,
  1793.                       (LONG)ListBoxWndProc3d);
  1794.               hwndEdit = GetWindow(hwndList, GW_HWNDNEXT);
  1795.             if (hwndEdit != NULL)
  1796.             SetWindowLong(hwndEdit, 
  1797.                           GWL_WNDPROC, 
  1798.                          (LONG)EditWndProc3d);
  1799.          return TRUE;
  1800.       }
  1801.       return FALSE;
  1802.    }
  1803.     else if ((pcs->style & 0x0003) == CBS_DROPDOWN)
  1804.    {
  1805.         // Subclass edit so bottom border of the edit draws properly.
  1806.       // This case is specially handled in ListEditPaint3d
  1807.       // The combo will not be subclassed
  1808.         hwndEdit = GetWindow(hwndCombo, GW_CHILD);
  1809.         if (hwndEdit != NULL)
  1810.             SetWindowLong(hwndEdit, 
  1811.                           GWL_WNDPROC, 
  1812.                          (LONG)EditWndProc3d);
  1813.         return FALSE;
  1814.    }
  1815.    return TRUE;     //dropdown lists
  1816.  
  1817. }
  1818.  
  1819.